package com.ht.miscorservice.demo.server.controller;

import com.hanthink.common.swagger.annotation.ApiVersion;
import com.hanthink.common.swagger.constant.ApiVersionConstant;
import com.ht.miscorservice.demo.server.entity.SysUserEntity;
import com.ht.miscorservice.demo.server.fegin.Test1FeignService;
import com.ht.miscorservice.demo.server.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author: tyh
 * @Date: 2022-04-01
 * @Description: Demo控制层
 */

@Api(tags = "首页模块")
@RestController
@Slf4j
@RequestMapping("/test1")
public class DemoInnerTestController {
  @Autowired
  private SysUserService userService;

  @Autowired
  private Test1FeignService testFeignService;


  @ApiImplicitParam(name = "name",value = "姓名",required = true)
  @ApiOperation(value = "向客人问好")
  @GetMapping("/hello")
  @ApiVersion(group = ApiVersionConstant.v1)
  public ResponseEntity<String> sayHi(@RequestParam(value = "name")String name){

    List<SysUserEntity> admin = userService.list(SysUserEntity.getWapper().eq(SysUserEntity::getUserName, name));
    log.info("服务1约定调用服务2:{}",testFeignService.getResultData(name));
    log.info("服务1暴露调用服务2:{}",testFeignService.demoList("服务1通过对外暴露接口调用..."));

    return ResponseEntity.ok("Hi:"+admin.toString());
  }


  @GetMapping("/call")
  public ResponseEntity<String> call(){

      return ResponseEntity.ok("服务1");
  }



}
